/**
 * @author hoang.pt
 * @version $Id: Problem1.java 126 2010-09-01 06:45:15Z phantichhoang $
 */

package homework.homework1.problem1;

/**
 * Target build tower
 * @author hoang.pt
 */
class Runnable2 implements Runnable {
	
	/**
	 * constructor
	 */
	public Runnable2() {
	}

	/**
	 * Print tower
	 * @author hoang.pt
	 */
	@Override
	public void run() {
		
		//print each line
		for (int i=1; i<=5; i++) {
			//---print space, install technique
			for (int j=1; j<=5-i; j++) {
				System.out.print(" ");
			}
			
			//---print *
			for (int k=1; k<=2*i-1; k++) {
				System.out.print("*");
			}
			
			//---print Enter
			System.out.print("\n");
			
			//after each line pause 1s			
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
	}
	
}





/**
 * square
 * @author hoang.pt
 */
class Thread2 extends Thread {
	
	/**
	 * Run thread
	 * @author hoang.pt
	 */
	public void run() {
		//print each line
		for (int i=1; i<=5; i++) {
			System.out.println(i*i);
			
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
			
	}
	
}



/**
 * Run 2 thread
 * @author hoang.pt
 */
public class Problem1 {

	/**
	 * constructor
	 */
	public Problem1() {
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		//init thread 1 and run using Interface
		Runnable2 r = new Runnable2();
		Thread t1 = new Thread(r);
		t1.start();
		
		
		//init thread 2 and run using Thread
		Thread2 t2= new Thread2();
		t2.start();
		
	}
}
